<?php
/**
 *  * *    author 韩天尊
 * *    Date: 2022/4/1
 * *    Email: <724700483@qq.com>
 */

namespace App\Toolys;
use EasySwoole\HttpAnnotation\Exception\Exception;
use Throwable;

/**
 * 自定义http错误拦截
 *
 *  $customHttpException = new CustomHttpException();
    $customHttpException->setCode(400)->setMessage("xxxxxx");
    throw $customHttpException;
 */
class CustomHttpException extends Exception
{
    protected $data = [];

    public function setMessage(string $message)
    {
        $this->message = $message;
        return $this;
    }

    public function setData(array $dada)
    {
        $this->data = $dada;
        return $this;
    }

    public function setCode(int $code)
    {
        $this->code = $code;
        return $this;
    }

    public function getData()
    {
        return $this->data;
    }
}